<?php
declare(strict_types=1);

namespace App\ZxAdmin\Users\Log;

use App\Controller;
use Field\SysUserPointsLogConst;
use Field\SysUserPointsLogColumns;
use Field\SysUserPointsLogRow;

// hook controller_zx_admin_users_log_points_use.php

/**
 * @title   佣金变化记录
 * @auth    true
 * @login   true
 * @menu    true
 * @component   vlist/index.vue
 * @icon    el-icon-ice-cream-round
 * @active  true
 * @affix   false
 * @rank    99
 */
class Points extends Controller
{
    // hook controller_zx_admin_users_log_points_public_start.php



    // hook controller_zx_admin_users_log_points_public_end.php

    /**
     * @title  下发配置
     * @rank    0
     */
    public function action_Conf_PUT()
    {
        // hook controller_zx_admin_users_log_points_conf_start.php
        $conf=['pageSize'=>0,'remoteSort'=>0,'remoteFilter'=>0,'remoteSummary'=>0,'hidePagination'=>0,'hideRefresh'=>0,'hideDo'=>0,'add'=>0,'start'=>0,'stop'=>0,'delete'=>0,'import'=>0,'export'=>0,'pageSizes'=>[10,20,25,50,100,500,1000,10000]];
        $Columns = [['table'=>'SysUserPointsLog','prop'=>'PointID','label'=>'id','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'UserID','label'=>'UID','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'ParentUserID','label'=>'推荐人','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'FromUserID','label'=>'来源用户','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'TypeID','label'=>'类型10收入20支出','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'Channel','label'=>'类型','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'Bonus','label'=>'金额','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'CreateAt','label'=>'时间','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'Status','label'=>'0未生效1有效2取消3退款4冻结','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'FrozenAt','label'=>'可用时间','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'FrozenY','label'=>'可用年','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'FrozenYm','label'=>'可用年月','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'FrozenYmd','label'=>'可用年月日','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'CashID','label'=>'提现单号','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'AuthTime','label'=>'时间','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'OrderID','label'=>'订单号','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0],['table'=>'SysUserPointsLog','prop'=>'Remak','label'=>'备注','hidden'=>1,'search'=>0,'add'=>0,'edit'=>0,'field'=>0,'sortable'=>0]];
        $Filter = [];
        $Tools = [];

        // hook controller_zx_admin_users_log_points_conf_end.php
        $this->response('0000', ['Conf' =>$conf, 'Filter' => $Filter, 'Tools' =>$Tools, 'Columns' => $Columns]);
    }

    /**
     * @title   下发列表数据
     * @rank    73
     */
    public function action_Index_GET()
    {
        // hook controller_zx_admin_users_log_points_index_start.php
        $page = $this->request->param('page', 0);
        $size = $this->request->param('limit', 0);
        $field = $this->request->param('field', 'PointID');
        $sort = $this->request->param('sort', -1);
        $order = [];
        !empty($field) && $order[$field] = $sort == 'asc' ? -1 : 1;
        $cond = [];
        
        $data = $this->SysUserPointsLog->GetList($cond, $order, $page, $size);
        
        foreach ($data['data'] as &$row) {
            
            //unset($row['PassWord'],$row['Salt']);
        }

        // hook controller_zx_admin_users_log_points_index_end.php
        $this->response('0000', $data);
    }
    
    
    
    

    
    /**
     * @title   启用
     * @rank    41
     */
    public function action_Enable_POST()
    {
        // hook controller_zx_admin_users_log_points_enable_start.php
        $data = $this->request->param('data', []);
        $cond=[];
        foreach ($data as $row){
                isset($row['PointID']) && $cond['PointID'][]=intval($row['PointID']);
        }
        $this->CheckEmpty($cond, ['待修改数据']);
        $r = $this->SysUserPointsLog->update($cond, [SysUserPointsLogConst::Status => 1]);
        // hook controller_zx_admin_users_log_points_enable_end.php
        $this->response($r ? '0000' : '0001', ['data' => $r],$r?'操作成功':'操作失败');
    }

    /**
     * @title   禁用
     * @rank    40
     */
    public function action_Disable_POST()
    {
        // hook controller_zx_admin_users_log_points_disable_start.php
        $data = $this->request->param('data', []);
        $cond=[];
        foreach ($data as $row){
                isset($row['PointID']) && $cond['PointID'][]=intval($row['PointID']);
        }
        $this->CheckEmpty($cond, ['操作数据为空']);
        $r = $this->SysUserPointsLog->update($cond, [SysUserPointsLogConst::Status => 0]);
        // hook controller_zx_admin_users_log_points_disable_end.php
        $this->response($r ? '0000' : '0001', ['data' => $r],$r?'操作成功':'操作失败');
    }
    
    
    /**
     * @title   下拉选择属性
     * @rank    30
     */
    public function action_Option_GET()
    {
        // hook controller_zx_admin_users_log_points_option_start.php

        $value = $this->request->param('value');
        $cond = [
            'OptionField'=>['LIKE'=>$value]
        ];
        $order = [];
        $list = $this->SysUserPointsLog->select($cond, $order, 1, 100);
        $data=[];
        foreach ($list as $row){
            $data[]=[
              'label'=>$row['OptionLabel'],
              'value'=>$row['OptionValue'],
            ];
        }
        // hook controller_zx_admin_users_log_points_option_end.php
        $this->response('0000', ['data' => $data]);
    }
    
    
    

      
     /**
      * @title   删除数据
      * @rank    50
      */
    public function action_Index_Delete()
    {
        // hook controller_zx_admin_users_log_points_delete_start.php
        $data = $this->request->param('data', []);
        $cond=[];
        foreach ($data as $row){
            isset($row['PointID']) && $cond['PointID'][]=intval($row['PointID']);
        }
        $this->CheckEmpty($cond, ['操作数据为空']);
        $r = $this->SysUserPointsLog->delete($cond);
        // hook controller_zx_admin_users_log_points_delete_end.php
        $this->response($r ? '0000' : '0001', ['data' => $r]);
    }
    
    // hook controller_zx_admin_users_log_points_end.php
}

?>